<template>
  <el-dialog
      title="提示"
      :visible.sync="dialogVisible"
      :close-on-click-modal="false"
      width="400px">
    <span style="font-size: 16px;font-weight: 500;text-align: center">{{ msg }}</span>
    <input v-model="reasonText" class="col6" style="width: 160px;height: 22px;margin-top: 10px" type="text"
           @input="changeData()"
           placeholder="请输入数据不合格原因" v-if="reason"/>
    <span slot="footer" class="dialog-footer">
            <el-button type="primary" @click="yes">是</el-button>
            <el-button @click="no">否</el-button>
        </span>
  </el-dialog>
</template>

<script>
export default {
  name: "Dialog",
  data() {
    return {
      reasonText: ""
    };
  },
  props: {
    dialogVisible: {
      type: Boolean,
      default: false
    },
    msg: {
      type: String,
      default: ""
    },
    reason: {
      type: Boolean,
      default: false
    }
  },
  methods: {
    yes() {
      this.$emit("yes");
    },
    no() {
      this.$emit("no");
    },
    changeData: function () {
      this.$emit("input", this.reasonText);
    }
  },
  watch: {
    dialogVisible(val) {
      if (val) {
        this.reasonText = "";
      }
    }
  }
};
</script>

<style scoped>

</style>
